import SmbRequest from "../tool/SmbRequest.js";
import NegotiateAgree from "../agreement/NegotiateAgree.js"
import SessionSetupAgree from "../agreement/SessionSetupAgree.js"
import TreeConnectAgree from "../agreement/TreeConnectAgree.js"
import {win32ErrorCodes} from "../enum/ErrCode.js"

export default class InitApi {


  static async init(connectObj){
    try{

      console.log("--- 商议协议 ---")
      let message = await SmbRequest.request(connectObj, NegotiateAgree)
  
      if (message.getStatus() != "0x00000000") {
        console.log("协议协商失败")
        return false;
      }
  
      console.log("--- 登录验证1 ---")
      let message1  = await SmbRequest.request(connectObj, SessionSetupAgree)

      console.log("--- 登录验证2 ---")
      let message2  = await SmbRequest.request(connectObj, SessionSetupAgree)
      if (message2.getStatus() != "0x00000000") {
        console.log("登录验证失败")
        return false;
      }

      console.log("--- tree连接 ---")
      let message3  = await SmbRequest.request(connectObj, TreeConnectAgree)

      

      
    }catch(e){
      console.log("验证出错", e)
      return false;
    }
    
    
   
   
     
   
   
 

  }

}